home *** CD-ROM | disk | FTP | other *** search
- (*----------------------------------------------------------------------*)
- (* Read_Line --- read line from file F *)
- (*----------------------------------------------------------------------*)
-
- PROCEDURE Read_Line;
-
- (*----------------------------------------------------------------------*)
- (* *)
- (* Procedure: Read_Line *)
- (* *)
- (* Purpose: Reads next line from file F and appends it to buffer. *)
- (* *)
- (* Calling sequence: *)
- (* *)
- (* Read_Line; *)
- (* *)
- (* Remarks: *)
- (* *)
- (* If the buffer is full the first Line in the buffer *)
- (* is deleted to make room. This operation "slides the buffer *)
- (* forward" one line on the file. If EOF(F) is TRUE on entry *)
- (* then no line is read, and Eof_Seen is set TRUE. Tabs are *)
- (* expanded, if Expands_Tabs is TRUE. If the high-order bits are *)
- (* to be stripped then the read is done character by character to *)
- (* avoid problems with "disguised" carriage returns. On entry F *)
- (* must be positioned at EOF or at the beginning of a line. On *)
- (* exit F is left positioned at EOF or at the beginning of the next *)
- (* line. *)
- (* *)
- (*----------------------------------------------------------------------*)
-
- VAR
- Line: STRING[Max_String];
- Inlen: INTEGER;
- c: CHAR;
- i: INTEGER;
- j: INTEGER;
- n: INTEGER;
-
- BEGIN (* Read_Line *)
-
- IF NOT EOF( F ) THEN
- BEGIN
- (* Figure position in line buffer *)
- IF Last = NIL THEN
- Last := First
- ELSE
- BEGIN
- Last := Last^.Next;
- IF Last = First THEN First := First^.Next
- END;
-
- WITH Last^ DO
- BEGIN
- (* Remember line number, page number *)
- (* of this line. *)
- Lnum := Cur_line;
- Pnum := Cur_page;
- (* Get text of line. *)
- (* If bit-stripping, check on a *)
- (* character by character basis for *)
- (* CR/LF combinations. *)
-
- IF ( NOT Strip_High ) THEN
- READ( F , Txt )
- ELSE
- BEGIN
-
- Txt := '';
-
- READ( F , C );
-
- C := CHR( ORD( C ) AND $7F );
-
- WHILE ( C <> CR ) DO
- BEGIN
- Txt := Txt + C;
- READ( F , C );
- C := CHR( ORD( C ) AND $7F );
- END;
-
- READ( F , C );
-
- END;
-
- (* Expand tabs if requested *)
- IF Expand_Tabs THEN
- BEGIN
-
- Line := Txt;
- Txt := '';
-
- Inlen := LENGTH( Line );
-
- i := 0;
- j := 0;
-
- WHILE ( j < Inlen ) AND ( i < Max_String ) DO
- BEGIN
-
- j := j + 1;
-
- c := Line[j];
-
- IF c = tab THEN
- BEGIN
-
- n := 8 - ( i - ORD( lpt ) ) mod 8;
-
- WHILE ( i < Max_String ) AND ( n > 0 ) DO
- BEGIN
- i := i + 1;
- Txt := Txt + ' ';
- n := n - 1;
- END;
-
- END
- ELSE
- Txt := Txt + c;
-
- END (* While *);
-
- END (* IF Expand_Tabs *);
-
- END (* With Last^ *) ;
-
- Readln_F;
-
- END
-
- ELSE
- Eof_Seen := TRUE;
-
- END (* Read_Line *);